/*
  { "value": 4, "des": "短信渠道" },
  { "value": 6, "des": "系统端" },
  { "value": 7, "des": "钉钉工作通知" },
  { "value": 10, "des": "邮件" },
  { "value": 11, "des": "钉钉机器人" },
  { "value": 12, "des": "钉钉企业群" }
*/
const CHANNEL_VALUE = {
  MESSAGE: '4',
  SYSTEM: '6',
  DING_TALK: '7',
  DING_ROBOT_TALK: '11',
  DING_QUN_TALK: '12',
  MPAAS: '20',
  MAIL: '10',
  LAN_XIN: '2',
  LAN_XIN_PLUS: '3'
};

const getChannalPlaceholder = (channelType, key, defaultValue) => {
  const map = {
    [CHANNEL_VALUE.DING_ROBOT_TALK]: { // 钉钉机器人
      corp_id: '钉钉机器人Webhook地址最后access_token密钥值',
      corp_secret: '钉钉机器人安全校验的sign加签',
    },

    [CHANNEL_VALUE.DING_TALK]: {// 钉钉工作通知
      corp_id: '钉钉小程序-凭证与基础信息-AppKey',
      corp_secret: '钉钉小程序-凭证与基础信息-AppSecret',
      agent_id: '钉钉小程序-凭证与基础信息-agentId',
    },
  };
  return (map[channelType] || {})[key] || defaultValue || '';
};

const getChannelText = (arr, channelValue) => {
  if (arr && arr.length > 0) {
    const obj = arr.find(item => item.value === channelValue);
    return obj && obj.des;
  }
  return '';
};

export { CHANNEL_VALUE, getChannelText, getChannalPlaceholder };
